home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18431 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: news.nevada.edu!not-for-mail
  2. From: morrisd@nevada.edu (DAMON MORRIS)
  3. Newsgroups: comp.lang.c++
  4. Subject: Return
  5. Date: 20 Apr 1996 13:04:43 GMT
  6. Organization: University of Nevada System Computing Services
  7. Message-ID: <4landb$345@news.nevada.edu>
  8. NNTP-Posting-Host: pioneer.nevada.edu
  9. NNTP-Posting-User: unauthenticated_user
  10. X-Newsreader: TIN [UNIX 1.3 950520BETA PL0]
  11.  
  12. I am having a really bad problem with some return statements...
  13. I declare a function to return an int value then in the function
  14. I check to see if two strings are equal and if so then I use another
  15. variable to see what to return...
  16.  
  17. int charisma(int ability, char *choice)
  18.  {
  19.   if (choice == "Loyalty Base")
  20.    {
  21.     if (ability==10) return 20;
  22.    }
  23.  }
  24.  
  25. This little program will never work for some reason. When I call it
  26. like this charisma(10,"Loyalty Base") it always returns some number
  27. that it shouldn't. The number that is returned is usually between
  28. 5000-10000. If I wrote the value of choice to the screen before it
  29. checked to see if it was equal to "Loyalty Base" it always says that
  30. it is equal to "Loyalty Base", yet it never gets to the second if.
  31. I have no idea what is the matter...I will send anyone full source if
  32. needed to fix the problem, but the source is 1000+ lines....
  33.  
  34.  
  35.